//
//  BaseTableViewController.swift
//  MySinaWeibo
//
//  Created by apple on 15/11/1.
//  Copyright © 2015年 baidu. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController, VisitorLoginViewDelegate {

//    用户登录标记
    var userLogon = UserAccount.userLogon
//      var userLogon = false
/// 访客视图
    var visitorView: VisitorLoginView?
    override func loadView() {
        
//        根据用户是否登录判断是否替换根视图
        userLogon ? super.loadView() : setUpVisitorView()
    }
    
//    设置访客视图
    private func setUpVisitorView() {
    
//        view = VisitorLoginView()
//        view.backgroundColor = UIColor.orangeColor()
        visitorView = VisitorLoginView()
        visitorView?.delegate = self
        view = visitorView
        
//   设置状态栏
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "VisitorLoginViewWillRegister")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "VisitorLoginViewWillLogin")
    }   
    
//    MARK: - VisitorLoginViewDelegate
    func VisitorLoginViewWillLogin() {
        
        let nav = UINavigationController(rootViewController: OAuthViewController())
        presentViewController(nav, animated: true, completion: nil)
    }
    func VisitorLoginViewWillRegister() {
        print("注册")
    }
}






















